/**
接口 inteface
如果我们定义了一个interface的变量，那么这个变量里面可以存实现这个interface的任意类型的对象
 *WangGANG
 *2018/9/6
 */
package main

import "fmt"

type Human struct {
	name string
	age int
	phone string
}

type Student struct {
	Human
	school string
	loan float32
}

type Employee struct {
	Human
	company string
	money float32
}

//接口
type Men interface {
	SayHi()
	Sing(lyrics string)
}

//实现接口
func (h Human) SayHi()  {
	fmt.Printf("Hi,I am %s you can call me on %s\n",h.name,h.phone)
}

//Human实现Sing方法
func (h Human) Sing(lyrics string) {
	fmt.Println("La la la la...", lyrics)
}

//Employee重载Human的SayHi方法
func (e Employee) SayHi() {
	fmt.Printf("Hi, I am %s, I work at %s. Call me on %s\n", e.name,
		e.company, e.phone)
}

func main() {
	mike := Student{Human{"Mike", 25, "222-222-XXX"}, "MIT", 0.00}
	sam := Employee{Human{"Sam", 36, "444-222-XXX"}, "Golang Inc.", 1000}

	//声明接口
	var i Men
	i = mike
	i.SayHi()

	i = sam
	i.Sing("Born to be wild")
	i.SayHi()
}